home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / internet / ghostzilla / ghsetup.exe / chrome / toolkit.jar / content / global / bindings / browser.xml next >
Encoding:
Extensible Markup Language  |  2002-05-21  |  12.9 KB  |  378 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4.    - The contents of this file are subject to the Mozilla Public
  5.    - License Version 1.1 (the "License"); you may not use this file
  6.    - except in compliance with the License. You may obtain a copy of
  7.    - the License at http://www.mozilla.org/MPL/
  8.    -
  9.    - Software distributed under the License is distributed on an "AS
  10.    - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11.    - implied. See the License for the specific language governing
  12.    - rights and limitations under the License.
  13.    -
  14.    - The Original Code is this file as it was released on
  15.    - March 28, 2001.
  16.    -
  17.    - The Initial Developer of the Original Code is Peter Annema.
  18.    - Portions created by Peter Annema are Copyright (C) 2001
  19.    - Peter Annema.  All Rights Reserved.
  20.    -
  21.    - Contributor(s):
  22.    -   Peter Annema <disttsc@bart.nl> (Original Author of <browser>)
  23.    -
  24.    - Alternatively, the contents of this file may be used under the
  25.    - terms of the GNU General Public License Version 2 or later (the
  26.    - "GPL"), in which case the provisions of the GPL are applicable
  27.    - instead of those above.  If you wish to allow use of your
  28.    - version of this file only under the terms of the GPL and not to
  29.    - allow others to use your version of this file under the MPL,
  30.    - indicate your decision by deleting the provisions above and
  31.    - replace them with the notice and other provisions required by
  32.    - the GPL.  If you do not delete the provisions above, a recipient
  33.    - may use your version of this file under either the MPL or the
  34.    - GPL.
  35.   -->
  36.  
  37. <bindings id="browserBindings"
  38.           xmlns="http://www.mozilla.org/xbl"
  39.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  40.  
  41.   <binding id="browser" extends="xul:browser">
  42.     <implementation type="application/x-javascript" implements="nsIAccessibleProvider">
  43.       <property name="accessible">
  44.         <getter>
  45.           <![CDATA[
  46.             var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  47.             return accService.createIFrameAccessible(this);
  48.           ]]>
  49.         </getter>
  50.       </property>
  51.  
  52.       <property name="canGoBack"
  53.                 onget="return this.webNavigation.canGoBack;"
  54.                 readonly="true"/>
  55.  
  56.       <property name="canGoForward"
  57.                 onget="return this.webNavigation.canGoForward;"
  58.                 readonly="true"/>
  59.  
  60.       <method name="goBack">
  61.         <body>
  62.           <![CDATA[
  63.             var webNavigation = this.webNavigation;
  64.             if (webNavigation.canGoBack)
  65.               webNavigation.goBack();
  66.           ]]>
  67.         </body>
  68.       </method>
  69.  
  70.       <method name="goForward">
  71.         <body>
  72.           <![CDATA[
  73.             var webNavigation = this.webNavigation;
  74.             if (webNavigation.canGoForward)
  75.               webNavigation.goForward();
  76.           ]]>
  77.         </body>
  78.       </method>
  79.  
  80.       <method name="reload">
  81.         <body>
  82.           <![CDATA[
  83.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  84.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  85.             this.reloadWithFlags(flags);
  86.           ]]>
  87.         </body>
  88.       </method>
  89.  
  90.       <method name="reloadWithFlags">
  91.         <parameter name="aFlags"/>
  92.         <body>
  93.           <![CDATA[
  94.             this.webNavigation.reload(aFlags);
  95.           ]]>
  96.         </body>
  97.       </method>
  98.  
  99.       <method name="stop">
  100.         <body>
  101.           <![CDATA[
  102.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  103.             const flags = nsIWebNavigation.STOP_ALL;
  104.             this.webNavigation.stop(flags);
  105.           ]]>
  106.         </body>
  107.       </method>
  108.  
  109.       <!-- throws exception for unknown schemes -->
  110.       <method name="loadURI">
  111.         <parameter name="aURI"/>
  112.         <parameter name="aReferrerURI"/>
  113.         <body>
  114.           <![CDATA[
  115.             const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
  116.             const flags = nsIWebNavigation.LOAD_FLAGS_NONE;
  117.             this.loadURIWithFlags(aURI, flags, aReferrerURI);
  118.           ]]>
  119.         </body>
  120.       </method>
  121.  
  122.       <!-- throws exception for unknown schemes -->
  123.       <method name="loadURIWithFlags">
  124.         <parameter name="aURI"/>
  125.         <parameter name="aFlags"/>
  126.         <parameter name="aReferrerURI"/>
  127.         <body>
  128.           <![CDATA[
  129.             if (!aURI)
  130.               aURI = "about:blank";
  131.  
  132.             this.webNavigation.loadURI(aURI, aFlags, aReferrerURI, null, null);
  133.           ]]>
  134.         </body>
  135.       </method>
  136.  
  137.       <method name="goHome">
  138.         <body>
  139.           <![CDATA[
  140.             try {
  141.               this.loadURI(this.homePage);
  142.             }
  143.             catch (e) {
  144.             }
  145.           ]]>
  146.         </body>
  147.       </method>
  148.  
  149.       <property name="homePage">
  150.         <getter>
  151.           <![CDATA[
  152.             var uri;
  153.  
  154.             if (this.hasAttribute("homepage"))
  155.               uri = this.getAttribute("homepage");
  156.             else
  157.               uri = "http://www.mozilla.org/"; // widget pride
  158.  
  159.             return uri;
  160.           ]]>
  161.         </getter>
  162.         <setter>
  163.           <![CDATA[
  164.             this.setAttribute("homepage", val);
  165.             return val;
  166.           ]]>
  167.         </setter>
  168.       </property>
  169.  
  170.       <method name="gotoIndex">
  171.         <parameter name="aIndex"/>
  172.         <body>
  173.           <![CDATA[
  174.             this.webNavigation.gotoIndex(aIndex);
  175.           ]]>
  176.         </body>
  177.       </method>
  178.  
  179.       <property name="currentURI"
  180.                 onget="return this.webNavigation.currentURI;"
  181.                 readonly="true"/>
  182.  
  183.       <property name="preferences"
  184.                 onget="return Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService);"
  185.                 readonly="true"/>
  186.  
  187.       <property name="docShell"
  188.                 onget="return this.boxObject.QueryInterface(Components.interfaces.nsIBrowserBoxObject).docShell;"
  189.                 readonly="true"/>
  190.  
  191.       <property name="webNavigation"
  192.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
  193.                 readonly="true"/>
  194.  
  195.       <property name="webBrowserFind"
  196.                 readonly="true"
  197.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebBrowserFind);"/>
  198.  
  199.       <property name="webProgress"
  200.                 readonly="true"
  201.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);"/>
  202.  
  203.       <property name="contentWindow"
  204.                 readonly="true"
  205.                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/>
  206.  
  207.       <property name="sessionHistory"
  208.                 onget="return this.webNavigation.sessionHistory;"
  209.                 readonly="true"/>
  210.  
  211.       <property name="markupDocumentViewer"
  212.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"
  213.                 readonly="true"/>
  214.  
  215.       <property name="contentViewerEdit"
  216.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"
  217.                 readonly="true"/>
  218.  
  219.       <property name="contentViewerFile"
  220.                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
  221.                 readonly="true"/>
  222.  
  223.       <property name="documentCharsetInfo"
  224.                 onget="return this.docShell.documentCharsetInfo;"
  225.                 readonly="true"/>
  226.  
  227.       <property name="contentDocument"
  228.                 onget="return this.webNavigation.document;"
  229.                 readonly="true"/>
  230.  
  231.       <field name="mPrefs" readonly="true">
  232.         Components.classes['@mozilla.org/preferences-service;1']
  233.                   .getService(Components.interfaces.nsIPrefService)
  234.                   .getBranch(null);
  235.       </field>
  236.  
  237.       <field name="_mStrBundle">null</field>
  238.  
  239.       <property name="mStrBundle">
  240.         <getter>
  241.         <![CDATA[
  242.           if (!this._mStrBundle) {
  243.             // need to create string bundle manually instead of using <xul:stringbundle/>
  244.             // see bug 63370 for details
  245.             var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
  246.                                   .getService(Components.interfaces.nsILocaleService);
  247.             var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
  248.                                   .getService(Components.interfaces.nsIStringBundleService);
  249.             var bundleURL = "chrome://global/locale/tabbrowser.properties";
  250.             this._mStrBundle = stringBundleService.createBundle(bundleURL, localeService.GetApplicationLocale());
  251.           }
  252.           return this._mStrBundle;
  253.         ]]></getter>
  254.       </property>
  255.  
  256.       <method name="addProgressListener">
  257.         <parameter name="aListener"/>
  258.         <body>
  259.           <![CDATA[
  260.             this.webProgress.addProgressListener(aListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
  261.           ]]>
  262.         </body>
  263.       </method>
  264.  
  265.       <method name="removeProgressListener">
  266.         <parameter name="aListener"/>
  267.         <body>
  268.           <![CDATA[
  269.             this.webProgress.removeProgressListener(aListener);
  270.          ]]>
  271.         </body>
  272.       </method>
  273.  
  274.       <field name="mDragDropHandler">
  275.         null
  276.       </field>
  277.  
  278.       <field name="securityUI">
  279.         null
  280.       </field>
  281.  
  282.       <constructor>
  283.         <![CDATA[
  284.           try {
  285.             if (!this.hasAttribute("disablehistory")) {
  286.               // wire up session history
  287.               this.webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(Components.interfaces.nsISHistory);
  288.  
  289.               // wire up global history
  290.               var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory);
  291.  
  292.               this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).globalHistory = globalHistory;      
  293.             }
  294.           }
  295.           catch (e) {
  296.           }
  297.           try {
  298.             this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"].createInstance(Components.interfaces.nsIDragDropHandler);
  299.             this.mDragDropHandler.hookupTo(this, null, null, null);
  300.           }
  301.           catch (e) {
  302.           }
  303.           try {
  304.             const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
  305.             if (!this.hasAttribute("disablesecurity") &&
  306.                 SECUREBROWSERUI_CONTRACTID in Components.classes) {
  307.               this.securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
  308.               this.securityUI.init(this.contentWindow);
  309.             }
  310.           }
  311.           catch (e) {
  312.           }
  313.         ]]>
  314.       </constructor>
  315.       
  316.       <destructor>
  317.         <![CDATA[
  318.           if (this.mDragDropHandler)
  319.             this.mDragDropHandler.detach();
  320.  
  321.           this.securityUI = null;
  322.         ]]>
  323.       </destructor>
  324.     </implementation>
  325.  
  326.     <handlers>
  327.       <handler event="keypress" keycode="VK_F7">
  328.         <![CDATA[
  329.           // Toggle browse with caret mode
  330.           var browseWithCaretOn = false;
  331.           var warn = true;
  332.  
  333.           try {
  334.             warn = this.mPrefs.getBoolPref("accessibility.warn_on_browsewithcaret");
  335.           } catch (ex) {
  336.           }
  337.  
  338.           try {
  339.             browseWithCaretOn = this.mPrefs.getBoolPref("accessibility.browsewithcaret");
  340.           } catch (ex) {
  341.           }
  342.           if (warn && !browseWithCaretOn) {
  343.             var checkValue = {value:false};
  344.             promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
  345.  
  346.             var buttonPressed = promptService.confirmEx(window, 
  347.               this.mStrBundle.GetStringFromName('browsewithcaret.checkWindowTitle'), 
  348.               this.mStrBundle.GetStringFromName('browsewithcaret.checkLabel'),
  349.               (promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
  350.               (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
  351.               this.mStrBundle.GetStringFromName('browsewithcaret.checkButtonLabel'),
  352.               null, null,
  353.               this.mStrBundle.GetStringFromName('browsewithcaret.checkMsg'), 
  354.               checkValue);
  355.             if (buttonPressed != 0)
  356.               return;
  357.             if (checkValue.value) {
  358.               try {
  359.                 this.mPrefs.setBoolPref("accessibility.warn_on_browsewithcaret", false);
  360.               }
  361.               catch (ex) {
  362.               }
  363.             }
  364.           }
  365.  
  366.           // Toggle the pref
  367.           try {
  368.             this.mPrefs.setBoolPref("accessibility.browsewithcaret",!browseWithCaretOn);
  369.           } catch (ex) {
  370.           }
  371.         ]]>
  372.       </handler>
  373.     </handlers>
  374.  
  375.   </binding>
  376.  
  377. </bindings>
  378.